#include <bits/stdc++.h>
// 2025/06/09
// tag:
// Author: Forever
using namespace std;
using int64 = int64_t;


const int N = 1501;
int n, t[N], f[N][3], fa[N];
vector<int> edge[N];

void dfs(int u, int fa)
{
    f[u][2] = t[u];
    int flag = 1e9;
    for (int v : edge[u]) {
        if (v == fa)
            continue;
        dfs(v, u);
        f[u][0] += min(f[v][1], f[v][2]);
        f[u][1] += min(f[v][1], f[v][2]);
        flag = min(flag, f[v][2] - min(f[v][1], f[v][2]));
        f[u][2] += min(f[v][0], min(f[v][1], f[v][2]));
    }
    if (flag != 1e9)
        f[u][1] += flag;
    else
        f[u][1] = 1e9;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int num, k, v;
        cin >> num >> t[num] >> k;
        for (int j = 1; j <= k; j++) {
            cin >> v;
            edge[num].push_back(v);
            edge[v].push_back(num);
            fa[v]++;
        }
    }
    dfs(1, 0);
    cout << min(f[1][1], f[1][2]) << endl;
    return 0;
}